package apportioner

import (
	// "bp/cache"
	"bp/conf"
	"bp/db"
	"bp/internal/nsqserver/producer"
	"bp/internal/service/entity"
	"go.uber.org/zap"
)

type ApportionerComServiceImp struct {
	dao            *db.PgDao
	slog           *zap.SugaredLogger
	vars           *conf.VarsSection
	pub            *producer.NsqProducerProxy
	entityHub      *entity.EntityHub
	apportionChans []chan ApportionTransactionID
}

// New initialization
func New(
	pgdao *db.PgDao,
	slog *zap.SugaredLogger,
	vars *conf.VarsSection,
	pub *producer.NsqProducerProxy,
	entityHub *entity.EntityHub,
) (s *ApportionerComServiceImp) {
	s = &ApportionerComServiceImp{
		dao:       pgdao,
		slog:      slog.With("module", "ApportionerComService"),
		vars:      vars,
		pub:       pub,
		entityHub: entityHub,
	}
	// 后期可以使用配置来决定worker数量
	s.apportionChans = s.runApportionWorkers(2)
	return
}
